<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>群发内容</title>
<script src="https://libs.baidu.com/jquery/1.10.2/jquery.min.js"></script>
<link rel="stylesheet" type="text/css" href="layui/css/layui.css" media="all">
<script type="text/javascript" src="js/base64/base64.js"></script>
<script type="text/javascript" src="layui/layui.js"></script>
<script type="text/javascript">

function ajax(msg) {
	var event = document.createEvent('MessageEvent');
	var origin = window.location.protocol + '//' + window.location.host;
	event.initMessageEvent('MessageReceived', true, true, msg, origin, 1234, window, null);
	document.dispatchEvent(event);
}
// 全局接收消息事件
function messageReceived(res) {
	res = Base64.decode(res);
	res = JSON.parse(res);

	//标签搜索
	if (res.type == "Search/User") {
		SearchUser(res.data);
	}
	if (res.type == "Tags/List") {
		tags_array = res.data;
		TagsList(res.data);
	}

}

</script>
<style type="text/css">
body{ padding: 10px; }
</style>
</head>
<body>

<form class="layui-form" action="">
  <div class="layui-form-item layui-form-text">
    <label class="layui-form-label">文本域</label>
    <div class="layui-input-block">
      <textarea id="content" placeholder="请输入内容" class="layui-textarea"></textarea>
    </div>
  </div>
   <div class="layui-form-item">
    <div class="layui-inline">
      <label class="layui-form-label">发布间隔</label>
      <div class="layui-input-inline" style="width: 100px;">
        <input type="text" name="interval" id="interval" onkeyup="this.value=this.value.replace(/[^0-9.]/g,'')" placeholder="1" autocomplete="off" class="layui-input">
      </div>
    </div>
  </div>
   <div class="layui-form-item">
    <div class="layui-inline">
      <label class="layui-form-label">日期</label>
      <div class="layui-input-inline">
        <input type="text" name="days" class="layui-input" id="test1" placeholder="yyyy-MM-dd">
      </div>
    </div>
  </div>
  <div class="layui-form-item">
	    <div class="layui-inline">
	      <label class="layui-form-label">发布间隔</label>
	      <div class="layui-input-inline">
			<input type="text" name="time" class="layui-input" id="test4" placeholder="HH:mm:ss">
	      </div>
	    </div>
   </div>
</form>

<div style="padding-top:50px;"> </div>
<div id="send" ><button id="Btn1" class="layui-btn layui-btn-fluid">发布</button></div>
</body>
<script>
layui.use(['form', 'layedit', 'laydate'], function(){
  var form = layui.form;
  var laydate = layui.laydate;

  //常规用法
  laydate.render({
    elem: '#test1'
  });
  //时间选择器
  laydate.render({
    elem: '#test4'
    ,type: 'time'
  });

});

	/*获取选中的id值*/
		$("#Btn1").click(function(){
			var content = $("#content").val();
			var days = $("#test1").val();
			var time = $("#test4").val();
			var interval = $("#interval").val();
			var data_opt = {
				type: "Add",
				data: {
					content : content,
					days : days,
					time : time,
					interval :  interval
				}
			}
			data_opt = JSON.stringify(data_opt);
			ajax(data_opt);
		});
</script>
</html>
